package com.hjxr.xmgl.web.controller;

import java.util.List;

import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.xmgl.web.domain.ProjectEarlyWarningResult;
import com.hjxr.xmgl.web.service.IProjectEarlyWarningResultService;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;


/**
 * 预警结果Controller
 *
 * @author hjxr
 * @date 2021-12-02
 */
@RestController
@RequestMapping("/system/result")
public class ProjectEarlyWarningResultController extends BaseController
{
    @Autowired
    private IProjectEarlyWarningResultService projectEarlyWarningResultService;

    /**
     * 查询预警结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjectEarlyWarningResult projectEarlyWarningResult)
    {
        startPage();
        List<ProjectEarlyWarningResult> list = projectEarlyWarningResultService.selectProjectEarlyWarningResultList(projectEarlyWarningResult);
        return getDataTable(list);
    }

    /**
     * 导出预警结果列表
     */
    @PreAuthorize("@ss.hasPermi('system:result:export')")
    @Log(title = "预警结果", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProjectEarlyWarningResult projectEarlyWarningResult)
    {
        List<ProjectEarlyWarningResult> list = projectEarlyWarningResultService.selectProjectEarlyWarningResultList(projectEarlyWarningResult);
        ExcelUtil<ProjectEarlyWarningResult> util = new ExcelUtil<ProjectEarlyWarningResult>(ProjectEarlyWarningResult.class);
        return util.exportExcel(list, "result");
    }

    /**
     * 获取预警结果详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:result:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(projectEarlyWarningResultService.selectProjectEarlyWarningResultById(id));
    }

    /**
     * 新增预警结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:add')")
    @Log(title = "预警结果", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectEarlyWarningResult projectEarlyWarningResult)
    {
        return toAjax(projectEarlyWarningResultService.insertProjectEarlyWarningResult(projectEarlyWarningResult));
    }

    /**
     * 修改预警结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:edit')")
    @Log(title = "预警结果", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectEarlyWarningResult projectEarlyWarningResult)
    {
        return toAjax(projectEarlyWarningResultService.updateProjectEarlyWarningResult(projectEarlyWarningResult));
    }

    /**
     * 删除预警结果
     */
    @PreAuthorize("@ss.hasPermi('system:result:remove')")
    @Log(title = "预警结果", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(projectEarlyWarningResultService.deleteProjectEarlyWarningResultByIds(ids));
    }
}
